package br.com.lh.urabuilder.command
{
	import br.com.lh.urabuilder.domain.xml.UraAction;
	import br.com.lh.urabuilder.event.SavePropertiesEvent;
	import br.com.lh.urabuilder.model.UraModelLocator;
	
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import mx.validators.Validator;
	
	public class SavePropertiesCommand implements ICommand
	{
		protected var uraModelLocator:UraModelLocator; 
		
		public function SavePropertiesCommand()	{
			 uraModelLocator= UraModelLocator.getInstance();
		}
		
		public function execute(event:CairngormEvent):void{
			if (validateForm(SavePropertiesEvent(event).element)){
				doUpdate(SavePropertiesEvent( event ).element);
			}
			uraModelLocator.selectableComponents.updateSelectableList();
			if (uraModelLocator.uraPropertiesForm !=null){
				uraModelLocator.uraPropertiesForm.updatePanel();
			}
		}
		
		protected function doUpdate(element:UraAction):void{
			uraModelLocator.xmlManager.updateElement(element);
		}
		
		private function validateForm(element:UraAction):Boolean{
			return true;
		}
		
		

	}
}